package com.yunpuvip.sachet.biz.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunpuvip.sachet.biz.entity.Order;
import com.yunpuvip.sachet.biz.entity.Payment;
import com.yunpuvip.sachet.biz.model.params.OrderParam;
import com.yunpuvip.sachet.biz.model.result.OrderResult;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunpuvip.sachet.modular.page.LayuiPageInfo;
import com.yunpuvip.sachet.modular.vo.rest.request.OrderQueryVo;
import com.yunpuvip.sachet.modular.vo.rest.request.RechargeVo;
import com.yunpuvip.sachet.modular.vo.rest.response.OrderVo;
import com.yunpuvip.sachet.modular.vo.rest.response.RechargePrePayVo;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 订单信息 服务类
 * </p>
 *
 * @author wushaohong
 * @since 2019-08-10
 */
public interface OrderService extends IService<Order> {

    /**
     * 新增
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    void add(OrderParam param);

    /**
     * 删除
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    void delete(OrderParam param);

    /**
     * 更新
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    void update(OrderParam param);

    /**
     * 查询单条数据，Specification模式
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    OrderResult findBySpec(OrderParam param);

    /**
     * 查询列表，Specification模式
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    List<OrderResult> findListBySpec(OrderParam param);

    /**
     * 查询分页数据，Specification模式
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
     LayuiPageInfo findPageBySpec(OrderParam param);


    /**
     * 用户充值
     * @param playerId
     * @param rechargeVo
     * @return
     */
     RechargePrePayVo userRechagePack(Integer playerId, RechargeVo rechargeVo);

    /**
     * 用户下单
     * @param playerId
     * @param rechargeVo
     * @return
     */

     RechargePrePayVo userOrderPack(Integer playerId, RechargeVo rechargeVo);



    /**
     * 根据订单号获取订单
     * @param orderNO
     * @return
     */
     Order getOrderByorderNo(String orderNO);

    /**
     * 根据缴费单获取订单
     * @param paymentId
     * @return
     */
    Order getOrderBypaymentId(Integer paymentId);

    /**
     *
     * @param vo
     * @return
     */
    Page<OrderVo> getOrderByCondition(OrderQueryVo vo);

    /**
     * 订单和缴费都加上余额支付
     * @param sunAmount
     * @param payment
     */
    void changeOrderPayPrice(BigDecimal sunAmount,Payment payment);

    /**
     * 退回用户余额
     * @param paymentId
     * @return
     */
    boolean  drawBackUserBalance(Integer paymentId);


    /**
     * 获取订单
     * @param orderId
     * @return
     */
    OrderVo getOrderById(Integer orderId);

    /**
     * 修改过期订单
     */
    void updateExpiredOrder();


    /**
     * 为订单生成二维码
     * @param orderId
     */
    String createAndUploadQrcode(Integer orderId,String uploadPath);

}
